<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of sendMail
 *
 * @author zhangxuelin
 */
class sendMail extends CI_Controller {
    function sendEmail(){
        $fromTitle = $_REQUEST['fromtitle'];
        $toEmail = $_REQUEST['toemail'];
        $emailTitle = $_REQUEST['emailtile'];
        $emailContent = $_REQUEST['emailContent'];
        $fromTitle       = empty($fromTitle) ? '中骏森驰OA' : $fromTitle;
        $toEmail         = empty($toEmail) ? 'zhangxuelin@gensenauto.com' : $toEmail;
        $emailTitle      = empty($emailTitle) ? '邮件标题' : $emailTitle;
        $emailContent    = empty($emailContent) ? '邮件内容' : $emailContent;
        
        $this->load->library('email'); 
        $config['protocol'] = 'smtp'; 
        $config['smtp_host'] = 'smtphz.qiye.163.com'; 
        $config['smtp_user'] = 'admin@gensenauto.com'; 
        $config['smtp_pass'] = '1QAZ2wsx'; 
        $config['mailtype'] = 'html';
        $config['validate'] = true;
        $config['priority'] = 1;
        $config['smtp_port'] = '25'; 
        $config['smtp_timeout'] = '10'; 
        $config['newline'] = "\r\n"; 
        $config['crlf'] = "\r\n"; 
        $config['wordwrap'] = TRUE;
        $config['charset'] = 'utf-8';
        $this->email->initialize($config); 
        
        $this->email->from('admin@gensenauto.com',$fromTitle); 
        $this->email->to($toEmail); 
        $this->email->subject($emailTitle); 
        $this->email->message($emailContent); 
        //$this->email->send(); 
        if($this->email->send())
        {
            //成功信息
            echo "发送成功";
        }
        else
        {
            //失败信息
            echo $this->email->print_debugger();
       }
 
    }
}
